import { createRouter, createWebHashHistory } from "vue-router";

const navRouter = [{
  path: "/",
  name: "Home",
  redirect: "/project/list",
  component: () => import(/* webpackChunkName: "Project" */ "../pages/project/project.vue"),
  children: [
    {
      path: "project",
      name: "MyProject",
      component: () => import(/* webpackChunkName: "my-project" */ "../pages/my-project/index.vue"),
      children: [
        {
          path: "list",
          name: "MyProjectList",
          component: () => import(/* webpackChunkName: "my-project-list" */ "../pages/my-project/my-project-list.vue"),
          meta: { title: "我的工程" }
        },
        {
          path: "page",
          name: "MyPageList",
          component: () => import(/* webpackChunkName: "my-page-list" */ "../pages/my-project/my-page-list.vue"),
          meta: { title: "我的页面" }
        },
      ]
    },
    {
      path: "data",
      name: "MyData",
      component: () => import(/* webpackChunkName: "my-data" */ "../pages/my-data/index.vue"),
      redirect: "/data/source",
      meta: { title: "我的数据" },
      children: [
        {
          path: "source",
          name: "MySource",
          component: () => import(/* webpackChunkName: "my-source-list" */ "../pages/my-data/my-source.vue"),
          meta: { title: "我的数据源" }
        },
        {
          path: "data",
          name: "MySourceData",
          component: () => import(/* webpackChunkName: "my-source-data" */ "../pages/my-data/my-data.vue"),
          redirect: "/data/data/index",
          meta: { title: "我的数据库" },
          children: [
            {
              path: "index",
              name: "MySourceDataIndex",
              component: () => import(/* webpackChunkName: "my-source-data" */ "../pages/my-data/my-data-type/my-data-index.vue"),
              meta: { title: "我的数据库-index" }
            },
            {
              path: "api",
              name: "MySourceDataAPI",
              component: () => import(/* webpackChunkName: "my-source-data-api" */ "../pages/my-data/my-data-type/my-data-api.vue"),
              meta: { title: "我的数据库-api" }
            },
            {
              path: "csv",
              name: "MySourceDataCSV",
              component: () => import(/* webpackChunkName: "my-source-data-csv" */ "../pages/my-data/my-data-type/my-data-csv.vue"),
              meta: { title: "我的数据库-csv" }
            },
            {
              path: "sql",
              name: "MySourceDataSQL",
              component: () => import(/* webpackChunkName: "my-source-data-sql" */ "../pages/my-data/my-data-type/my-data-sql.vue"),
              meta: { title: "我的数据库-sql" }
            },
            {
              path: "etl",
              name: "MySourceDataETL",
              component: () => import(/* webpackChunkName: "my-source-data-etl" */ "../pages/my-data/my-data-type/my-data-etl.vue"),
              meta: { title: "我的数据库-etl" }
            },
          ]
        },
      ]
    },
    {
      path: "com",
      name: "MyCom",
      component: () => import(/* webpackChunkName: "my-com" */ "../pages/my-com/my-com.vue"),
      meta: { title: "我的组件" }
    },
    {
      path: "case",
      name: "MyCase",
      component: () => import(/* webpackChunkName: "my-case" */ "../pages/my-case/my-case.vue"),
      meta: { title: "教程" }
    }
  ]
}];

const routes = [{
  path: "/login",
  name: "Login",
  component: () => import(/* @vite-ignore */ /* webpackChunkName: "Login" */ "../pages/login/login.vue")
},
...navRouter,
{
  path: "/test",
  name: "Test",
  component: () => import(/* @vite-ignore */ /* webpackChunkName: "Test" */ "../pages/test/test.vue")
},
{
  path: "/eleTest",
  name: "eleTest",
  component: () => import(/* @vite-ignore */ /* webpackChunkName: "Test" */ "../pages/test/eleTest.vue")
},
{
  path: "/design/:id",
  name: "Design",
  component: () => import(/* @vite-ignore */ /* webpackChunkName: "design" */ "../pages/design/design.vue")
}, {
  path: "/screen/preview/:screenId",
  name: "Preview",
  props: true,
  component: () => import(/* webpackChunkName: "screen" */ "../pages/screen/index.vue"),
},];

const Router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default Router;
